package com.hmall.item.config;


import com.hmall.item.constants.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class MqConfig {
    @Bean
    public Queue upQueue(){
        return new Queue(MqConstants.UP_QUEUE);
    }
    @Bean
    public Queue downQueue(){
        return new Queue(MqConstants.DOWN_QUEUE);
    }

    @Bean
    public TopicExchange exchange(){
        return new TopicExchange(MqConstants.HMALL_EXCHANGE);
    }

    @Bean
    public Binding bindingUpQueue(Queue upQueue, TopicExchange exchange){
        return BindingBuilder.bind(upQueue).to(exchange).with(MqConstants.UP_KEY);
    }
    @Bean
    public Binding bindingDownQueue(Queue upQueue, TopicExchange exchange){
        return BindingBuilder.bind(upQueue).to(exchange).with(MqConstants.DOWN_KEY);
    }
}
